/**
 * 负责利用传入的FeatureLayer图层进行空间查询操作，并返回查询结果
 */
define([
        "dojo/_base/declare",
        "esri/geometry/SpatialReference",
        "esri/tasks/GeometryService",
        "esri/geometry/Point",
        "esri/tasks/support/ProjectParameters"
    ],
    function (declare,SpatialReference, GeometryService, Point,ProjectParameters) {
        return declare(null, {
            /**
             * 获取素有通用的元素
             */
            elements:function(){

            },
            constructor: function () {
            },

            /**
             * 坐标转换
             */
            lngLatToXY:function (lng,lat,onSuccess) {
                let gsvc = new GeometryService("https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

                let PrjParams = new ProjectParameters();

                PrjParams.outSR = new SpatialReference({wkid: 4528});//需要输出的坐标系

                PrjParams.geometries = [];//几何类型数组，比如多个点可以批量转换
                let point1 = new Point(lng, lat, new SpatialReference({wkid: 4326}));
                // let point2 = new Point(116, 36.5, new SpatialReference({wkid: 4326}));
                PrjParams.geometries.push(point1);
                // PrjParams.geometries.push(point2);

                //点的坐标转换，地理坐标(wkid:4326)转为投影坐标(wkid:4528)
                gsvc.project(PrjParams).then(function (resGeoms) {
                    if (typeof onSuccess=='function'){
                        onSuccess(resGeoms);
                    }
                });
            },


        });
    });



